import request from '@/plugins/request'
import { IResponseData } from '@/types/request-base'
import { json2FormData } from '@/utils'

// 立面相关接口

/**
 * 查询验收区域下的所有立面及相关信息
 * @param {string} amid 区域ID
 * @param {string} reportModel 整改类型：  0.全部 1.未整改 2.已整改
 */
export function queryModuleAllFacade({ amid, reportModel = 0 }: any) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/TaskManage/GetAcceptModuleAllFacade`,
    params: { amid, reportModel }
  })
}

/**
 * 查询单个立面详情
 * @param {string} sfid 立面ID
 */
export function queryFacadeDetail(sfid: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/TaskManage/GetAcceptFacade?sfid=${sfid}`
  })
}

/**
 * 查询单个问题详情
 * @param {string} ffid 问题ID
 */
export function queryFacadeFile(ffid: string) {
  return request<IResponseData>({
    method: 'get',
    url: `/app/TaskManage/GetAcceptFacadeFile?ffid=${ffid}`
  })
}

/**
 * 验收立面保存
 * @param {object} data  保存参数对象 {caid:'验收ID'，amid:'区域ID'，facade：'立面数'}
 */
export function saveFacade(data: any) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/SaveAcceptFacade`,
    params: data,
    errorShow: true
  })
}

/**
 * 更新立面状态
 * @param {string} sfid  立面ID
 */
export function SaveFacadeStatus(sfid: string) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/SaveFacadeStatus`,
    params: { sfid }
  })
}

/**
 * 记录当前验收最后一次验收立面 (废弃)
 * @param {object} data  保存参数对象 {amid:'区域ID' , facade：'立面数'}
 */
export function saveCheckFacade(data: any) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/SaveCheckFacade`,
    params: data
  })
}

/**
 * 删除验收立面信息
 * @param {string} guid  验收区域立面问题id
 */
export function deleteFacadeFile(guid: any) {
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/DeleteAcceptFacadeFile?guid=${guid}`,
    errorShow: true
  })
}

/**
 * 立面信息保存 FFID为00000000-0000-0000-0000-000000000000新增
 * @param {string} data  立面信息 {}
 */
export function saveFacadeFile(data: any) {
  if (!data.ffid) {
    data.ffid = '00000000-0000-0000-0000-000000000000'
  }
  return request<IResponseData>({
    method: 'POST',
    url: `/app/TaskManage/SaveAcceptFacadeFile`,
    data,
    headers: {
      repeatSubmit: false
    },
    loading: true,
    errorShow: true
  })
}
